home *** CD-ROM | disk | FTP | other *** search
- /*
- HASUtilPrint.c from Hsoi's App Shell © 1995-1997 John C. Daub. All Rights Reserved.
-
- This file is a wee different than the rest of the shell. (Currently) this file
- contains only one function, HsoiSetSpacing. This function manipulates some of
- the inner data structures on a WASTE instance (namely the LineArrayHandle in
- the WERec).
-
- This is nice and fun because it allows us to print the text double-spaced (this
- function is only used during the printing loop to create a double-spaced print out,
- and this function is ONLY used upon a clone of the original WE instance. do
- NOT use this function on your original WE instance else suffer the possible
- consequences). If you happen to do that, WECalText MIGHT be able to fix it
- for you, but no guarentees.
-
- anyways, since this function manipulates some private WASTE stuff, we have
- to #include WASTEIntf.h instead of WASTE.h, and we also must put this function
- in a file seperate from the rest of the shell.
-
- Also notice that we declare the function prototype here (with a WEHandle for
- WASTEIntf.h compatability), but then "redeclare" it in HASUtilPrint.h
- (with a WEReference). The first is to force no compiler errors/warnings.
- the second, to allow this fuction to be called by other functions in the
- shell.
-
- Hopefully this all makes sense.
-
- This routine was based upon the Pascal Tex-Edit+ 1.6.3 source by Tom
- Bender. I translated it to C (with the help of Ken Long, Dan Crevier,
- and John Solhurst...the last line was a pain...all 3 of these guys
- tried it, and Dan's was the closest...it actually compiled but was
- a little off...it was an easy fix).
-
- I've left the original Pascal code in just in case someone might
- spot an error :)
-
- */
-
- #pragma mark ••• #includes •••
-
- #include "WASTEIntf.h"
- // note: HASUtilPrint.h isn't #included here...see above for why. instead,
- // here's the only function prototype we need.
-
- #pragma mark -
- #pragma mark ••• Function Prototypes •••
-
- void HsoiSetSpacing( WEHandle we );
-
- #pragma mark -
-
- // here's the original Pascal version
-
- /*
- procedure SetSpacing (txtHdl: WEHandle);
-
- { This procedure is called by DoPrint to double the line spacing for printing. }
-
- var
- x: longint;
- theLineCount: longint;
- theLineArrayHandle: LineArrayHandle;
-
- begin { SetSpacing }
- theLineCount := WECountLines(txtHdl);
- theLineArrayHandle := tWEHandle(txtHdl)^^.hLines;
- for x := 1 to theLineCount do
- theLineArrayHandle^^[x].lineOrigin := 2 * theLineArrayHandle^^[x].lineOrigin
- end; { end of SetSpacing }
- */
-
-
- // here is the C translation
-
- void HsoiSetSpacing( WEHandle we )
- {
- long x;
- long lineCount;
- WELineArrayHandle lineArray;
- SignedByte weState;
-
- // i don't know how necessary it is to lock the WEHandle and the
- // LineArrayHandle, but considering what we're doing, it can't hurt
- // (tho i'm sure there won't be any interrupt calls here, can't hurt)
-
- weState = HGetState( (Handle)we );
- HLock( (Handle)we );
-
- lineCount = WECountLines( we );
-
- lineArray = (*we)->hLines;
-
- HLock( (Handle)lineArray );
-
- // this for loop was the translation problem *bleck*. hopefully this is
- // totally right...it seems to work no problem.
-
- for ( x = 1; x <= lineCount; x++ )
- ((*lineArray)[x]).lineOrigin = 2 * ((*lineArray)[x]).lineOrigin;
-
- HUnlock( (Handle)lineArray );
- HSetState((Handle)we, weState );
-
- return;
- }
-
-
- // here's another way of doing this that Marco Piovanelli sent me:
- /*
- void SetSpacing( WEHandle hWE )
- {
- LinePtr pLine;
- long lineIndex, nLines;
-
- nLines = WECountLines( hWE );
-
- pLine = *(*hWE)->hLines;
- for ( lineIndex = 0; lineIndex < nLines; lineIndex++ )
- {
- pLine->lineOrigin *= 2;
- pLine++;
- }
- }
- */